﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
                    xmlns:conv="clr-namespace:USElections.Converters;assembly=USElections.Converters"
                    xmlns:command="clr-namespace:USElections.Command">

    <conv:PartyToColorConverter x:Key="ptc" />
    <conv:HasImageVisibilityConverter x:Key="hasImage" />
    <command:PinToStartCommand x:Key="pin" />

    <DataTemplate x:Key="candidatesItemTemplate">
        <!-- if accessible -->
        <Grid Width="173"
              Height="173"
              Background="Transparent"
              Margin="0">

            <toolkit:HubTile Title="{Binding FullName}"
                             Message="{Binding Party, StringFormat='{0} Party'}"
                             Background="{Binding Party, Converter={StaticResource ptc}}"
                             IsFrozen="True"
                             GroupTag="CandidatesGroup"
                             Width="173"
                             Height="173"
                             Visibility="{Binding Converter={StaticResource hasImage}}">
                    <toolkit:HubTile.Source>
                    <BitmapImage UriSource="{Binding ImageUri}"
                                 CreateOptions="BackgroundCreation" />
                </toolkit:HubTile.Source>
                <toolkit:ContextMenuService.ContextMenu>
                    <toolkit:ContextMenu>
                        <toolkit:MenuItem Header="pin to start"
                                          Command="{StaticResource pin}"
                                          CommandParameter="{Binding}" />
                    </toolkit:ContextMenu>
                </toolkit:ContextMenuService.ContextMenu>
            </toolkit:HubTile>


            <Border Width="173"
                    Height="173"
                    Background="{Binding Party, Converter={StaticResource ptc}}"
                    Visibility="{Binding Converter={StaticResource hasImage}, ConverterParameter=True}"
                    Margin="0">
                <Grid>
                    <TextBlock FontSize="{StaticResource PhoneFontSizeNormal}"
                               FontFamily="{StaticResource PhoneFontFamilyNormal}"
                               LineStackingStrategy="BlockLineHeight"
                               LineHeight="23.333"
                               Margin="10,10,10,6"
                               TextWrapping="Wrap"
                               Text="{Binding Party, StringFormat='{0} Party'}" />
                    <TextBlock FontSize="{StaticResource PhoneFontSizeNormal}"
                               FontFamily="{StaticResource PhoneFontFamilySemiBold}"
                               Margin="10,0,0,6"
                               TextWrapping="NoWrap"
                               VerticalAlignment="Bottom"
                               Text="{Binding FullName}" />
                </Grid>
            </Border>
        </Grid>
    </DataTemplate>
</ResourceDictionary>